<template>
  <div class="newMusicItem" @click="playMusic">
    <img :src="picUrl" />
    <span class="songName">{{musicName}}</span>
    <span class="singer">{{singer}}</span>
    <div class="icon"><i class="iconfont icon-bofang"></i></div>
  </div>
</template>

<script>
export default {
  name: "NewMusicItem",
  props: ["picUrl", "musicName", "singer", "songID"],
  methods:{
    playMusic(){
      this.$store.dispatch('play/updateSongId',this.songID)
    }
  }
};
</script>

<style lang="less" scoped>
.newMusicItem {
  width: 250px;
  height: 50px;
  position: relative;
  border-radius: 5px;
  margin-bottom: 15px;
  img {
    width: 50px;
    height: 50px;
    border-radius: 5px;
  }
  span {
    font-weight: lighter;
    font-size: 14px;
    display: block;
    position: absolute;
    word-wrap: break-word; /*强制换行*/
    overflow: hidden; /*超出隐藏*/
    text-overflow: ellipsis; /*隐藏后添加省略号*/
    white-space: nowrap; /*强制不换行*/
    height: auto;
    width: 150px;
    overflow: hidden;
  }
  .songName {
    top: 5px;
    left: 60px;
  }
  .singer {
    top: 30px;
    left: 65px;
    color: #333;
    font-size: 12px;
  }
  // icon图标样式
  .icon {
    position: absolute;
    left: 14px;
    top: 14px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8);
    i {
      display: block;
      margin-top: 4px;
      margin-left: 5px;
      color: #ff7a9e;
      font-size: 12px;
    }
  }
}
</style>